home *** CD-ROM | disk | FTP | other *** search
/ HyperLib 1997 Winter - Disc 1 / HYPERLIB-1997-Winter-CD1.ISO.7z / HYPERLIB-1997-Winter-CD1.ISO / オンラインウェア / PRG / WASTE Object Handlers 1.2.2.sit / WASTE Object Handlers 1.2.2 / Handler Source / WE_PICT_Handler.c < prev    next >
Text File  |  1996-07-18  |  3KB  |  116 lines

  1. // PICT Object Handler for the WASTE Text Engine
  2. // by Michael F. Kamprath, kamprath@kagi.com
  3. // maintenance by John C. Daub, hsoi@eden.com
  4. //
  5. // v1.0, 12 March 1995
  6. // v1.1, 5 June 1995,     Added InstallPICTObject() to install the PICT handler
  7. //                        by itself.
  8. // v1.2, 28 March 1996. Minor updates.  Added precompiler directives, WASTE 1.2a5 compatability
  9. //
  10. // v1.2.2, 16 July 1996. Added compatability with WASTE 1.2 and CW9
  11. //                         Restructured installation routines
  12.  
  13. #ifndef _WASTE_
  14. #include "WASTE.h"
  15. #endif
  16.  
  17. #include "WE_PICT_Handler.h"
  18.  
  19. #ifndef _WASTEOBJECTS_
  20. #include "WASTE_Objects.h"
  21. #endif
  22.  
  23.  
  24. //
  25. // InstallPICTObject()
  26. //        Installs the PICT handler into WASTE.
  27. //
  28. OSErr    InstallPICTObject( WEReference theWE )
  29. {
  30. OSErr    iErr;
  31.  
  32. #ifdef __cplusplus
  33.     static WENewObjectUPP            newPICTUPP = NewWENewObjectProc(HandleNewPicture);
  34.     static WEDisposeObjectUPP        disposePICTUPP = NewWEDisposeObjectProc(HandleDisposePicture);
  35.     static WEDrawObjectUPP            drawPICTUPP = NewWEDrawObjectProc(HandleDrawPicture);
  36. #else
  37.     static WENewObjectUPP            newPICTUPP = NULL;
  38.     static WEDisposeObjectUPP        disposePICTUPP = NULL;
  39.     static WEDrawObjectUPP            drawPICTUPP = NULL;
  40.  
  41.  
  42.     if ( newPICTUPP == NULL )
  43.         newPICTUPP = NewWENewObjectProc(HandleNewPicture);
  44.     if ( disposePICTUPP == NULL )
  45.         disposePICTUPP = NewWEDisposeObjectProc(HandleDisposePicture);
  46.     if ( drawPICTUPP == NULL )
  47.         drawPICTUPP = NewWEDrawObjectProc(HandleDrawPicture);
  48. #endif
  49.  
  50.     if ( newPICTUPP != NULL )
  51.         iErr = WEInstallObjectHandler(kTypePicture, weNewHandler, (UniversalProcPtr)newPICTUPP, theWE);
  52.     else
  53.         iErr = weUnknownObjectTypeErr;
  54.     if (iErr) return(iErr);
  55.     
  56.     if ( disposePICTUPP != NULL )
  57.         iErr = WEInstallObjectHandler(kTypePicture, weDisposeHandler, (UniversalProcPtr)disposePICTUPP, theWE);
  58.     else
  59.         iErr = weUnknownObjectTypeErr;
  60.     if (iErr) return(iErr);
  61.     
  62.     if ( drawPICTUPP != NULL )
  63.         iErr = WEInstallObjectHandler(kTypePicture, weDrawHandler, (UniversalProcPtr)drawPICTUPP, theWE);
  64.     else
  65.         iErr = weUnknownObjectTypeErr;
  66.     if (iErr) return(iErr);
  67.     
  68.     return(noErr);
  69. }
  70.  
  71. //
  72. // New Object Handler for PICTs
  73. //
  74. pascal OSErr    HandleNewPicture(Point *defaultObjectSize,WEObjectReference objectRef)
  75. {
  76. PicHandle    thePic;
  77. Rect        theFrame;
  78.  
  79.     thePic = (PicHandle)WEGetObjectDataHandle(objectRef);
  80.     
  81.     theFrame = (*thePic)->picFrame;
  82.     
  83.     OffsetRect(&theFrame, -theFrame.left, -theFrame.top);
  84.     
  85.     *defaultObjectSize = botRight(theFrame);
  86.         
  87.     return(noErr);
  88. }
  89.  
  90. //
  91. // Dispose Object Handler for PICTS
  92. //
  93. pascal OSErr    HandleDisposePicture(WEObjectReference objectRef )
  94. {
  95. PicHandle    thePic;
  96.  
  97.     thePic = (PicHandle)WEGetObjectDataHandle(objectRef);
  98.     
  99.     if (thePic)
  100.         KillPicture(thePic);
  101.  
  102.     return(MemError());
  103. }
  104. //
  105. // Draw Object Handler for PICTs
  106. //
  107. pascal OSErr    HandleDrawPicture (Rect *destRect, WEObjectReference objectRef )
  108. {
  109. PicHandle    thePic;
  110.     
  111.     thePic = (PicHandle)WEGetObjectDataHandle(objectRef);
  112.  
  113.     DrawPicture(thePic, destRect);
  114.             
  115.     return( noErr );
  116. }